﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TraceThisItem.Domain;

namespace TraceThisItem.WebUI.Projects
{
	public partial class Create : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{

		}

		protected void CreateProjectButton_Click(object sender, EventArgs e)
		{
			if (Page.IsValid)
			{
				Facade.Instance.AddProject(new Project
				{
					Name = ProjectName.Text.Trim(),
					Owner = Facade.Instance.GetUser(ProjectOwner.SelectedValue),
					CreatedOn = DateTime.Now
				});
				Response.Redirect("~/Projects");
			}
		}

		protected void UserDataSource_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
		{
			e.ObjectInstance = Facade.Instance;
		}
	}
}